<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="vue.js"></script>
  <style>
    li {
      margin-top: 10px;
    }
  </style>
</head>

<body>
  <div id="app">

    <button @click="add">change</button>
    <ul ref="oul">
      <li v-for="(item,index) in list" :key="index">
        {{index}}
      </li>
    </ul>

  </div>
  <script>
    new Vue({
      el: "#app",
      data: {
        isShow: true,
        list: [1]
      },
      methods: {
        add() {
          this.list.push(11); //数据改变 渲染视图是异步的
          let oul = this.$refs['oul'];
          /* this.$nextTick(() => {
            let ali = oul.children;
            for (var i = 0; i < ali.length; i++) {
              ali[i].style.background = "blue";
            }
          }) */
          Vue.nextTick(()=>{
            let ali = oul.children;
            for (var i = 0; i < ali.length; i++) {
              ali[i].style.background = "blue";
            }
          })
        }
      }
    })
  </script>
</body>

</html>